#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QUdpSocket>
#include <QTableWidgetItem>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT
private:
    QUdpSocket *udpSocket;

    enum frameTypeEnum{order};
    enum cellType{
        zhuohao,time,jine,chuanfendain,
        maodun,doufun,qingyoumalahuoguon,
        tesezhanliaon,columnyangpaijuann
    };
    enum tableColumnnumber{
        columnzhuohao=0 ,columntime=0,columnjine,columnchuanfendai,
        columnmaodu,columndoufu,columntesezhanliao,
        columnqingyoumalahuoguo,columnyangpaijuan
    };
    int account;
    struct order{
        int zhuohao;
        int jine;
        int chuanfendain;
        int maodun;
        int doufun;
        int qingyoumalahuoguon;
        int tesezhanliaon;
        int yangpaijuann;
        QString time;
    };
    QList<struct order*> orderL;
    QList<QTableWidgetItem*> itemPointerL;

    bool isFrame(QByteArray datagram);
    frameTypeEnum frameType(QByteArray frame);
    void frameHandle(frameTypeEnum Type,QByteArray datagram);
    void addAnOrderToTable(int row,struct order* const o);
    void addAnOrderToTableWithZhuoHao(int row,struct order* const o);
    void deleteTable();
public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
private slots:
    void do_udpSocket_readyRead();

    void on_comboBox_tableNumber_currentTextChanged(const QString &arg1);

    void on_pushButton_settle_clicked();

private:
    Ui::Widget *ui;
};
#endif // WIDGET_H
